package com.ta.gulimall.gulimall.elasticsearch.controller;

import com.ta.gulimall.common.view.to.UpSpuInfoTo;
import com.ta.gulimall.common.utils.system.R;
import com.ta.gulimall.gulimall.elasticsearch.service.ElasticsearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/elasticsearch")
public class ElasticsearchController {
    @Autowired
    ElasticsearchService elasticsearchService;

    /**
     * 上架的spu商品信息保存到elasticsearch
     * @param upSpuInfoToList
     * @return
     */
    @PostMapping("/productSave")
    public R productSave(@RequestBody List<UpSpuInfoTo> upSpuInfoToList){
        elasticsearchService.productSave(upSpuInfoToList);

        return R.ok();
    }

}
